<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:replace="~{common/header :: commonHead}"></head>
<META HTTP-EQUIV="Cache-Control" CONTENT= "no-cache, must-revalidate">
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight" th:with="page=${pageObj.page},size=${pageObj.pageSize},total=${pageObj.total},totalPage=${pageObj.totalPage},keyword=${pageObj.keyword},fromDate=${pageObj.fromDate},toDate=${pageObj.toDate}">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>停车缴费记录</h5>
                    <div class="ibox-tools">
                        <shiro:hasPermission name="export_parking_record">
                            <a th:href="${#lists.isEmpty(pageObj.list)?'javascript:nodata();':'/ketop_parking/export_parking_record?total='+total+'&keyword='+(keyword==null?'':keyword)+'&fromDate='+(fromDate==null?'':fromDate)+'&toDate='+(toDate==null?'':toDate)}" title="导出停车缴费记录"><i class="glyphicon glyphicon-export"></i></a>
                        </shiro:hasPermission>
                        <a href="javascript: window.location.href='/ketop_parking/parking_record';" title="刷新"><i class="glyphicon glyphicon-repeat"></i></a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="">
                    </div>
                    <div id="editable_wrapper" class="dataTables_wrapper form-inline" role="grid">
                        <div class="row">
                            <div class="col-sm-4">
                                <div class="dataTables_length" id="editable_length"><label>每页
                                <select name="editable_length" aria-controls="editable" class="form-control input-sm" id="page_size_selector">
                                    <option th:selected="${size eq 5}" value="5">5</option>
                                    <option th:selected="${size eq 10}" value="10">10</option>
                                    <option th:selected="${size eq 25}" value="25">25</option>
                                    <option th:selected="${size eq 50}" value="50">50</option>
                                    <option th:selected="${size eq 100}" value="100">100</option>
                                </select> 条记录</label>
                                </div>
                            </div>


                            <div class="col-sm-3">
                                <div class="input-daterange input-group" id="datepicker">
                                    <input type="text" class="input-sm form-control" name="start" id="start_date" placeholder="开始时间" th:value="${pageObj.fromDate}">
                                    <span class="input-group-addon">到</span>
                                    <input type="text" class="input-sm form-control" name="end" id="end_date" placeholder="结束时间" th:value="${pageObj.toDate}">
                                </div>
                            </div>
                            <div class="col-sm-3">
                                <div class="input-group" style="float: right">
                                    <input th:value="${keyword}" type="text" placeholder="请输入关键词" class="input-sm form-control" id="search_bar">
                                    <span class="input-group-btn">
                                        <button type="button" class="btn btn-sm btn-primary" id="search-btn"> 搜索</button>
                                    </span>
                                </div>
                            </div>
                        </div>
                        <div class="datepicker datepicker-dropdown dropdown-menu datepicker-orient-left datepicker-orient-bottom" style="display: none; top: 901.2px; left: 264.8px; z-index: 10;"><div class="datepicker-days" style="display: block;"><table class=" table-condensed"><thead><tr><th class="prev" style="visibility: visible;">«</th><th colspan="5" class="datepicker-switch">十一月 2014</th><th class="next" style="visibility: visible;">»</th></tr><tr><th class="dow">日</th><th class="dow">一</th><th class="dow">二</th><th class="dow">三</th><th class="dow">四</th><th class="dow">五</th><th class="dow">六</th></tr></thead><tbody><tr><td class="old day">26</td><td class="old day">27</td><td class="old day">28</td><td class="old day">29</td><td class="old day">30</td><td class="old day">31</td><td class="day">1</td></tr><tr><td class="day">2</td><td class="day">3</td><td class="day">4</td><td class="day">5</td><td class="day">6</td><td class="day">7</td><td class="day">8</td></tr><tr><td class="day">9</td><td class="day">10</td><td class="selected day">11</td><td class="range day">12</td><td class="range day">13</td><td class="range day">14</td><td class="range day">15</td></tr><tr><td class="range day">16</td><td class="active selected day">17</td><td class="day">18</td><td class="day">19</td><td class="day">20</td><td class="day">21</td><td class="day">22</td></tr><tr><td class="day">23</td><td class="day">24</td><td class="day">25</td><td class="day">26</td><td class="day">27</td><td class="day">28</td><td class="day">29</td></tr><tr><td class="day">30</td><td class="new day">1</td><td class="new day">2</td><td class="new day">3</td><td class="new day">4</td><td class="new day">5</td><td class="new day">6</td></tr></tbody><tfoot><tr><th colspan="7" class="today" style="display: none;">今天</th></tr><tr><th colspan="7" class="clear" style="display: none;">清空</th></tr></tfoot></table></div><div class="datepicker-months" style="display: none;"><table class="table-condensed"><thead><tr><th class="prev" style="visibility: visible;">«</th><th colspan="5" class="datepicker-switch">2014</th><th class="next" style="visibility: visible;">»</th></tr></thead><tbody><tr><td colspan="7"><span class="month">1</span><span class="month">2</span><span class="month">3</span><span class="month">4</span><span class="month">5</span><span class="month">6</span><span class="month">7</span><span class="month">8</span><span class="month">9</span><span class="month">10</span><span class="month active">11</span><span class="month">12</span></td></tr></tbody><tfoot><tr><th colspan="7" class="today" style="display: none;">今天</th></tr><tr><th colspan="7" class="clear" style="display: none;">清空</th></tr></tfoot></table></div><div class="datepicker-years" style="display: none;"><table class="table-condensed"><thead><tr><th class="prev" style="visibility: visible;">«</th><th colspan="5" class="datepicker-switch">2010-2019</th><th class="next" style="visibility: visible;">»</th></tr></thead><tbody><tr><td colspan="7"><span class="year old">2009</span><span class="year">2010</span><span class="year">2011</span><span class="year">2012</span><span class="year">2013</span><span class="year active">2014</span><span class="year">2015</span><span class="year">2016</span><span class="year">2017</span><span class="year">2018</span><span class="year">2019</span><span class="year new">2020</span></td></tr></tbody><tfoot><tr><th colspan="7" class="today" style="display: none;">今天</th></tr><tr><th colspan="7" class="clear" style="display: none;">清空</th></tr></tfoot></table></div></div>
                        <table class="table table-striped table-bordered table-hover  dataTable" id="editable"
                               aria-describedby="editable_info">
                            <thead>
                                <tr role="row">
                                    <th aria-label="车牌号" style="width: 10%;" >车牌号</th>
                                    <th aria-label="用户名" style="width: 10%;" >用户名</th>
                                    <th aria-label="用户手机号" style="width: 10%;" >用户手机号</th>
                                    <th aria-label="用户卡号" style="width: 10%;" >用户卡号</th>
                                    <th aria-label="订单号" style="width: 10%;" >订单号</th>
                                    <th aria-label="总费用(单位：元)" style="width: 10%;">总费用(单位：元)</th>
                                    <th aria-label="单次抵扣费用(单位：元)" style="width: 10%;" >单次抵扣费用(单位：元)</th>
                                    <th aria-label="支付方式" style="width: 10%;" >支付方式</th>
                                    <th aria-label="缴费时间" style="width: 10%;">缴费时间</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr class="gradeA odd" th:if="${#lists.isEmpty(pageObj.list)}">
                                    <td colspan="11" style="text-align: center">
                                        没有数据o&gt;^&lt;o
                                    </td>
                                </tr>
                                <tr class="gradeA odd" th:each="item : ${pageObj.list}">
                                    <td th:with="plateNumber=${item.plateNum}" th:utext="${null == keyword ? plateNumber : #strings.replace(plateNumber,keyword,'<span style= &quot;color: red;font-weight:bold&quot;>'+ keyword +'</span>')}"></td>
                                    <td th:with="nickName=${item.nickName}" th:utext="${null == keyword ? nickName : #strings.replace(nickName,keyword,'<span style= &quot;color: red;font-weight:bold&quot;>'+ keyword +'</span>')}"></td>
                                    <td th:with="phone=${item.phone}" th:utext="${null == keyword ? phone : #strings.replace(phone,keyword,'<span style= &quot;color: red;font-weight:bold&quot;>'+ keyword +'</span>')}"></td>
                                    <td th:with="memberCard=${item.memberCard}" th:utext="${null == keyword ? memberCard : #strings.replace(memberCard,keyword,'<span style= &quot;color: red;font-weight:bold&quot;>'+ keyword +'</span>')}"></td>
                                    <td th:with="orderNo=${item.orderNo}" th:utext="${null == keyword ? orderNo : #strings.replace(orderNo,keyword,'<span style= &quot;color: red;font-weight:bold&quot;>'+ keyword +'</span>')}"></td>
                                    <td th:text="${item.totalFeeYuan}"></td>
                                    <td th:text="${item.totalFreeFeeYuan}"></td>
                                    <td th:text="${item.disTypeString}"></td>
                                    <td th:text="${item.payTime}"></td>
                                </tr>
                            </tbody>
                        </table>
                        <div class="row">
                            <div class="col-sm-6">
                                <div class="dataTables_info" role="alert" aria-live="polite" aria-relevant="all"
                                     th:text="${'显示 '
                                      + (page * size + 1)
                                      + ' 到 '
                                      + ((page+1) lt totalPage ? (size + page * size) : (total % size == 0 ? total : (total % size + size * page)))
                                      + ' 项，共 '
                                      + total + ' 项 ' + totalPage + ' 页'}">
                                </div>
                            </div>
                            <div class="col-sm-6">
                                <div class="dataTables_paginate paging_simple_numbers">
                                    <ul class="pagination" th:if="${totalPage>1}">
                                        <li th:class="${page==0}?'paginate_button previous disabled':'paginate_button previous'">
                                            <a th:href="${(page==0)?'#':'/ketop_parking/parking_record?page='+page
                                             +'&pageSize='+size
                                             +'&keyword='+(null==keyword?'':keyword)
                                             +'&fromDate='+(null==fromDate?'':fromDate)
                                             +'&toDate='+(null==toDate?'':toDate)}">上一页</a>
                                        </li>
                                        <li th:if="${totalPage<10}" th:each="i:${#numbers.sequence(1,totalPage)}"
                                            th:class="${i==page+1?'active':''}">
                                            <a th:href="${'/ketop_parking/parking_record?page='+i
                                            +'&pageSize='+size
                                            +'&keyword='+ (null==keyword?'':keyword)
                                            +'&fromDate='+(null==fromDate?'':fromDate)
                                            +'&toDate='+(null==toDate?'':toDate)}"
                                               th:text="${i}" ></a>
                                        </li>
                                        <li th:if="${page<4&&totalPage>=9}" th:each="i:${#numbers.sequence(1,9)}"
                                            th:class="${i==page+1?'active':''}">
                                            <a th:href="${'/ketop_parking/parking_record?page='+i
                                            +'&pageSize='+size
                                            +'&keyword='+ (null==keyword?'':keyword)
                                            +'&fromDate='+(null==fromDate?'':fromDate)
                                            +'&toDate='+(null==toDate?'':toDate)}"
                                               th:text="${i}" ></a>
                                        </li>
                                        <li th:if="${page>=4&&totalPage>=9&&page+5<totalPage}" th:each="i:${#numbers.sequence(page - 3,page + 5)}"
                                            th:class="${i==page+1?'active':''}">
                                            <a th:href="${'/ketop_parking/parking_record?page='+i
                                            +'&pageSize='+size
                                            +'&keyword='+ (null==keyword?'':keyword)
                                            +'&fromDate='+(null==fromDate?'':fromDate)
                                            +'&toDate='+(null==toDate?'':toDate)}"
                                               th:text="${i}" ></a>
                                        </li>
                                        <li th:if="${page>=4&&totalPage>=9&&page+5>=totalPage}" th:each="i:${#numbers.sequence(totalPage - 8,totalPage)}"
                                            th:class="${i==page+1?'active':''}">
                                            <a th:href="${'/ketop_parking/parking_record?page='+i
                                            +'&pageSize='+size
                                            +'&keyword='+ (null==keyword?'':keyword)
                                            +'&fromDate='+(null==fromDate?'':fromDate)
                                            +'&toDate='+(null==toDate?'':toDate)}"
                                               th:text="${i}" ></a>
                                        </li>
                                        <li th:class="${page+1==totalPage||totalPage<1}?'paginate_button next disabled':'paginate_button next'" >
                                            <a th:href="${(page+1==totalPage||totalPage<1) ? '#' : '/ketop_parking/parking_record?page='+(page+2)
                                             +'&pageSize='+size
                                             +'&keyword='+(null==keyword?'':keyword)
                                             +'&fromDate='+(null==fromDate?'':fromDate)
                                             +'&toDate='+(null==toDate?'':toDate)}">下一页</a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script th:inline="javascript">
    function nodata(){
        layer.msg("暂无数据，不支持导出",{time: 500})
    }
    $("#page_size_selector").change(function () {
        let fromDate = $("#start_date").val();
        let toDate = $("#end_date").val();
        let selected = $(this).val();
        window.location.href = initUrl(0,selected,'',fromDate,toDate,'');
    })
    $("#search_bar").keydown(function (e) {
        let fromDate = $("#start_date").val();
        let toDate = $("#end_date").val();
        if (e.keyCode == 13) {
            let size = $("#page_size_selector").val();
            let keyword = $(this).val();
            window.location.href = initUrl(0,size,keyword,fromDate,toDate);
        }
    })

    $("#search-btn").click(function () {
        let fromDate = $("#start_date").val();
        let toDate = $("#end_date").val();
        let size = $("#page_size_selector").val();
        let keyword = $("#search_bar").val();
        window.location.href = initUrl(0,size,keyword,fromDate,toDate);
    })

    function initUrl(page,size,key,fromDate,toDate) {
        if (null == page) {
            page = 0;
        }
        return "/ketop_parking/parking_record?page="+ page +"&pageSize=" + size + "&keyword=" + key + "&fromDate=" + fromDate + "&toDate=" + toDate
    }
</script>
</html>